package com.project.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.project.bean.PersonBase.MouseBean;
import com.project.mapper.IMouseMapper;
import com.project.service.IMouseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class IMouseServiceImpl extends ServiceImpl<IMouseMapper, MouseBean> implements IMouseService {


    @Override
    public IPage<MouseBean> findCutMouse(int pageNo, int pageSize, String mouseName) {

        Page<MouseBean> page = new Page<>(pageNo,pageSize);

        QueryWrapper wrapper = new QueryWrapper<>();

        if (mouseName != null){
            wrapper.like("mouse_name",mouseName);
        }

        IPage<MouseBean> mouseBeanIPage = this.baseMapper.selectPage(page,wrapper);

        return mouseBeanIPage;
    }

    @Override
    public void addMouse(MouseBean mouseBean) {

        this.baseMapper.insert(mouseBean);

    }

    @Override
    public MouseBean findMouseById(int mouseId) {

        return this.baseMapper.selectById(mouseId);

    }
}
